<template>
  <div>
      检查单详情
      <button @click="paramsEncrypt()">获取检查单详情</button>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        starparams:{
                // 网关待加密 参数
          url:'/openapi/examinePrescription/detail',
          method:'POST',
          data:{
            "orderNo": '413545351314555544'
          }
        },
      }
    },
    methods:{
       test(){

      },
      detailData(newherders){
        // let newherders = await this.paramsEncrypt(this.starparams)

        this.$http.post('http://ext.api.sxftech.com/openapi/examinePrescription/detail',
          {"orderNo":'413545351314555544'},{headers:newherders}).then(res=>{
            console.log(res)
        })
      },
      paramsEncrypt() {
        let ctx = this.starparams
        const source = 'ybt'
        const target = 'sxftech-business-his'
        const privateKey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJz27xZCQANXFTbpNpG70FuXILNSav6vPNT6hXlz3QHxCrPMJ2V8AzQIewJp126E+bpW0cSN/hicswlUcm2zFBcli0giFye+uW4yysYW2KFZ+BqMAW7Qr0bQOKa9+vYunwd9pzGcJCr3drFmcuM72VNswjZYKbTqytv8/Bqg3IzTAgMBAAECgYBeZ+Kq95O6rpCy4xeQFW8e90mSsRprLgifbEIFJ1ugxFIUi9CSKEFg9UzOycvpzA7LNVabKm/Oa8j+7oyYUCHfTMJTpadhVCMQoQcKyO76jg5y3BTbb4KGUZEeUop3Ay8isXqfgP1A1uhKPSB2AJ53gXIObfsDSjhEwFqzBHzVaQJBANCNp0eLBOKVkbUC8ILR7rAyOnfLP2skZoB2fb1cKOuFDKPq+CcXyRVFHxnLBW20+dvMPgT9+TMhYJ9jqAL9zH8CQQDArLPF1Eq9gjrvolXZEODcBajvk75tGJWVWjUVrxLmb0m8tw4HqrkoYxeh0M7T+kbSv4GxdRoIB6KaMBAptSWtAkBaSTjmDBUtUrsltgQRXnkK5nPRcLgf1j5Z1vJQjBla/NqgDBUqN23iO25faDkNaY/Ry/X9i0XbENQXrLkLsnxZAkBnCTROG/woIgewdMih/zOwldpE3GaeYuJDb20p/mkGEAeHwwDeur6vyWYu48Jne9T6CO2rX6sfFi4vdHqAQ141AkAcTfSCBGh9JvOngIffmKT8PZDdKHIDgZymHv2wjRW31RRWaY1fiYhvrtiWIzugWWMXmxDEpp60WRtFgkRY9WRB";


        console.log('ctxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',ctx)
        let params = JSON.stringify(ctx.data)
        console.log('paramsparamsparamsparamsparamsparamsparams',params)
        
        let jse = new this.$jsEncrypt.JSEncrypt()
        jse.setPublicKey(privateKey)
        let sign = jse.encrypt(params)


        // const key = new NodeRSA({
        //  b: 2048  //可以知道位数
        // });
        // key.importKey(privateKey, 'pkcs8'); //根据java端模式
        // key.setOptions({ signingScheme: 'sha1' });//指定加密格式
        // let sign = key.sign(params, 'base64', 'utf8');
        console.info('signsignsignsignsignsignsignsignsign',sign)
        debugger

        let herder = {
          'protocol':ctx.method,
          'path':ctx.url,
          'target':target,
          'source':source,
          'type':'signature'
        }

        console.log('herderherderherderherderherder',herder)

        base64herder = Buffer.from(JSON.stringify(herder)).toString('base64')
        console.log('base64herder',base64herder)

        let newherders = {
          'Accept':'application/json;charset=UTF-8',
          'Content-Type':'application/json;charset=UTF-8',
          'appid':source,
          'signature':sign,
          'header':base64herder
        } 

        // return newherders
        this.detailData(newherders)
      }

      
    }
  }
</script>

<style lang="scss" scoped>

</style>